import 'package:flutter/material.dart';
import './res/listData.dart';

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('你好flutter1')),
        body: const MyApp(),
      ),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  List<Widget> _initListData() {
    // TODO map循环
    return listData.map((item) {
      return ListTile(
        leading: Image.network(item['imageUrl']),
        title: Text('${item['title']}'),
        subtitle: Text('${item['author']}'),
      );
    }).toList();
  }

  @override
  Widget build(BuildContext context) {
    return ListView(
      children: _initListData(),
    );
  }
}
